﻿Option Strict On
Option Explicit On
'********************************************************************************
'*
'*      不良カテゴリー入力フォーム
'*
'*      File Name : frmLotCateInput.vb
'*      Title     : ロット集計・計上処理
'*      機能    　： ロット集計・計上
'*
'********************************************************************************
'----------------------------------<<修正履歴>>----------------------------------
'ﾊﾞｰｼﾞｮﾝ   日付       作業者        ｺﾒﾝﾄ
'--------- ---------- ------------ -----------------------------------------------
' V1.0.9   2015/08/23 M.Hiroki     新規作成
' V3.0.2   2018/01/13 安部         GroupKey対応
'********************************************************************************

Imports System.ComponentModel

Public Class frmLotCategoryInput

    Private cLotDefect As New clsDbLotDefect

    'コントロール配列のフィールドを作成
    Private btnCateAry() As System.Windows.Forms.Button
    Private btnKeyAry() As System.Windows.Forms.Button
    Private lblCountAry() As System.Windows.Forms.Label

    Private m_MsgData(50) As String

    Private CateMax As Integer = 70

    Private m_CategoryNo As Integer

    Private dtError As DataTable
    Private szLotNo As String
    Private szKouteiCD As String
    Private szEquipID As String
    Public preProcCompleteCnt As Double

    '不良数合計
    Private failCnt As Integer

    Public Property ErrorTable() As DataTable
        Get
            ErrorTable = dtError
        End Get
        Set(ByVal value As DataTable)
            dtError = value
        End Set
    End Property

    Public WriteOnly Property LotNo As String
        Set(ByVal value As String)
            szLotNo = value
        End Set
    End Property

    Public WriteOnly Property KouteiCD As String
        Set(ByVal value As String)
            szKouteiCD = value
        End Set
    End Property

    Public WriteOnly Property EquipID As String
        Set(ByVal value As String)
            szEquipID = value
        End Set
    End Property

    Public ReadOnly Property FailCount As Integer
        Get
            Return failCnt
        End Get
    End Property

    '******************************************************************************
    '*  フォームロード処理
    '******************************************************************************
    Private Sub frmLotCategoryInputLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        '表示ｻｲｽﾞをﾚｼﾞｽﾄﾘから取得　　' この数値は要確認：.NETではpixel
        Me.Top = CInt(GetSetting(My.Application.Info.AssemblyName, Me.Name, "Top", CStr(0)))
        Me.Left = CInt(GetSetting(My.Application.Info.AssemblyName, Me.Name, "Left", CStr(0)))

        'ボタンコントロール配列の作成 　　　　　　　　
        Me.btnCateAry = New System.Windows.Forms.Button(CateMax) {} '{btnCate1, btnCate2, btnCate3, btnCate4, btnCate5, btnCate6, btnCate7, btnCate8, btnCate9, btnCate10, btnCate11, btnCate12, btnCate13, btnCate14, btnCate15, btnCate16, btnCate17, btnCate18, btnCate19, btnCate20, btnCate21, btnCate22, btnCate23, btnCate24, btnCate25, btnCate26, btnCate27, btnCate28, btnCate29, btnCate30, btnCate31, btnCate32, btnCate33, btnCate34, btnCate35, btnCate36, btnCate37, btnCate38, btnCate39, btnCate40, btnCate41, btnCate42, btnCate43, btnCate44, btnCate45, btnCate46, btnCate47, btnCate48, btnCate49, btnCate50}
        Me.lblCountAry = New System.Windows.Forms.Label(CateMax) {}
        For i = 1 To CateMax
            If i <= 10 Then
                Me.btnCateAry(i) = CType(Me.TabPage1.Controls("btnCate" & i), Button)
                Me.lblCountAry(i) = CType(Me.TabPage1.Controls("lblCount" & i), Label)
            ElseIf i <= 20 Then
                Me.btnCateAry(i) = CType(Me.TabPage2.Controls("btnCate" & i), Button)
                Me.lblCountAry(i) = CType(Me.TabPage2.Controls("lblCount" & i), Label)
            ElseIf i <= 30 Then
                Me.btnCateAry(i) = CType(Me.TabPage3.Controls("btnCate" & i), Button)
                Me.lblCountAry(i) = CType(Me.TabPage3.Controls("lblCount" & i), Label)
            ElseIf i <= 40 Then
                Me.btnCateAry(i) = CType(Me.TabPage4.Controls("btnCate" & i), Button)
                Me.lblCountAry(i) = CType(Me.TabPage4.Controls("lblCount" & i), Label)
            ElseIf i <= 50 Then
                Me.btnCateAry(i) = CType(Me.TabPage5.Controls("btnCate" & i), Button)
                Me.lblCountAry(i) = CType(Me.TabPage5.Controls("lblCount" & i), Label)
            ElseIf i <= 60 Then
                Me.btnCateAry(i) = CType(Me.TabPage6.Controls("btnCate" & i), Button)
                Me.lblCountAry(i) = CType(Me.TabPage6.Controls("lblCount" & i), Label)
            ElseIf i <= 70 Then
                Me.btnCateAry(i) = CType(Me.TabPage7.Controls("btnCate" & i), Button)
                Me.lblCountAry(i) = CType(Me.TabPage7.Controls("lblCount" & i), Label)
            End If
            'Me.btnCateAry(i) = CType(Me.Controls("btnCate" & i), Button)
            'Me.lblCountAry(i) = CType(Me.Controls("lblCount" & i), Label)
        Next i

        Me.btnKeyAry = New System.Windows.Forms.Button(10) {}  '{btn0, btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9, btn10}
        For i = 0 To 10
            Me.btnKeyAry(i) = CType(Me.PanelKey.Controls("btn" & i), Button)
        Next

        'イベントハンドラに関連付け（必要な時のみ）
        For i = 1 To Me.btnCateAry.Length - 1
            AddHandler Me.btnCateAry(i).Click, AddressOf Me.btnCateAry_Click
        Next i

        For i = 0 To Me.btnKeyAry.Length - 1
            AddHandler Me.btnKeyAry(i).Click, AddressOf Me.btnKeyAry_Click
        Next i

        '文字内容をセット
        SetMsg()

        '初期化
        lblCateSel.Text = ""
        txtCateNum.Text = ""
        btnSet.Enabled = False
        PanelKey.Enabled = False
        btnCateNum.Enabled = False

        '不良カテゴリー取得＆表示処理
        DispCategoryInfo()
        '既存の不良数を入力
        SetErrorCount()
        '不良数合計計算
        defectNumCalc()
    End Sub

    '*****************************************************************************
    '　　フォームアンロード処理
    '*****************************************************************************
    Private Sub frmLotCategoryInput_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

        '表示ｻｲｽﾞをﾚｼﾞｽﾄﾘに保存
        SaveSetting(My.Application.Info.AssemblyName, Me.Name, "Top", CStr(Me.Top))
        SaveSetting(My.Application.Info.AssemblyName, Me.Name, "Left", CStr(Me.Left))

        For i = 1 To Me.btnCateAry.Length - 1
            RemoveHandler Me.btnCateAry(i).Click, AddressOf Me.btnCateAry_Click
        Next i

        For i = 0 To Me.btnKeyAry.Length - 1
            RemoveHandler Me.btnKeyAry(i).Click, AddressOf Me.btnKeyAry_Click
        Next i

        Me.btnCateAry = Nothing
        Me.btnKeyAry = Nothing


    End Sub

    '*****************************************************************************
    '　　終了処理
    '*****************************************************************************
    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click


        dtError = New DataTable
            dtError.Columns.Add("コード")
            dtError.Columns.Add("不良内容")
            dtError.Columns.Add("数量")


        Dim erroCount As Double = 0

        Dim i As Integer
        For i = 1 To CateMax
            If IsNumeric(lblCountAry(i).Text) OrElse String.IsNullOrEmpty(lblCountAry(i).Text) Then
                Dim dr() As DataRow = dtError.Select("不良内容='" & btnCateAry(i).Text & "'")
                If dr.Length <= 0 Then
                    dtError.Rows.Add(btnCateAry(i).Tag, btnCateAry(i).Text.Substring(InStr(btnCateAry(i).Text, ":")), lblCountAry(i).Text)
                    If Not lblCountAry(i).Text.Equals("") Then
                        erroCount = erroCount + CInt(lblCountAry(i).Text)
                    End If
                Else    
                    dr(0)("数量") = lblCountAry(i).Text
                End If
            End If
        Next

        '>> 2018/02/19 安部 検査数量タイプ 追加
        Dim rb1 As RadioButton
        Dim szTag As Integer

        szTag = 0

        'GroupBoxで選択されているRadioButtonを取得
        For Each rb1 In grpSampleType.Controls
            If (rb1.Checked) Then
                szTag = CInt(rb1.Tag)
            End If
        Next

        If szTag = 0 And erroCount > 0 Then
            MsgBox(getMsgStr("MSG10028"))

            Exit Sub
        End If
        '<< 2018/02/19 安部 検査数量タイプ 追加


        dtError.DefaultView.RowFilter = "数量<>''"
        '不良項目をDBに保存
        '>> 2018/02/19 安部 検査数量タイプ 追加
        'cLotDefect.SaveDefectData(szLotNo, g_CURRENT_EQUIP_ID, g_EQUIP_NO, dtError.DefaultView.ToTable, szKouteiCD)
        cLotDefect.SaveDefectData(szLotNo, g_CURRENT_EQUIP_ID, g_EQUIP_NO, dtError.DefaultView.ToTable, szKouteiCD, szTag)
        '<< 2018/02/19 安部 検査数量タイプ 追加

        Select Case g_CURRENT_EQUIP_TYPE
            Case DEF_ID_TAPE
                frmStartCompleteTape.ErrorTable = dtError.DefaultView.ToTable
                frmStartCompleteTape.dgvError.DataSource = frmStartCompleteTape.ErrorTable

                'ロット毎不良数ワークテーブル書込
                Call frmStartCompleteTape.RefleshLotBadData()

            'Case DEF_ID_BARCODE
            '    frmStartCompleteBarCode.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteBarCode.dgvError.DataSource = frmStartCompleteBarCode.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteBarCode.RefleshLotBadData()
            'Case DEF_ID_LASER_DICING
            '    frmStartCompleteLaserDicing.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteLaserDicing.dgvError.DataSource = frmStartCompleteLaserDicing.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteLaserDicing.RefleshLotBadData()
            Case DEF_ID_DIESER
                frmStartCompleteDicing.ErrorTable = dtError.DefaultView.ToTable
                frmStartCompleteDicing.dgvError.DataSource = frmStartCompleteDicing.ErrorTable

                'ロット毎不良数ワークテーブル書込
                Call frmStartCompleteDicing.RefleshLotBadData()
            Case DEF_ID_TAPE_UV
                frmStartCompleteTapeUV.ErrorTable = dtError.DefaultView.ToTable
                frmStartCompleteTapeUV.dgvError.DataSource = frmStartCompleteTapeUV.ErrorTable

                'ロット毎不良数ワークテーブル書込
                Call frmStartCompleteTapeUV.RefleshLotBadData()
            Case DEF_ID_DIC_CHK
                frmStartCompleteDicCheck.ErrorTable = dtError.DefaultView.ToTable
                frmStartCompleteDicCheck.dgvError.DataSource = frmStartCompleteDicCheck.ErrorTable

                'ロット毎不良数ワークテーブル書込
                Call frmStartCompleteDicCheck.RefleshLotBadData()

            Case DEF_ID_DB
                frmStartCompleteDB.ErrorTable = dtError.DefaultView.ToTable
                frmStartCompleteDB.dgvError.DataSource = frmStartCompleteDB.ErrorTable

                'ロット毎不良数ワークテーブル書込
                Call frmStartCompleteDB.RefleshLotBadData()
            Case DEF_ID_WB
                frmStartCompleteWB.ErrorTable = dtError.DefaultView.ToTable
                frmStartCompleteWB.dgvError.DataSource = frmStartCompleteWB.ErrorTable

                'ロット毎不良数ワークテーブル書込
                Call frmStartCompleteWB.RefleshLotBadData()
            'Case DEF_ID_INSP
            '    frmStartCompleteAsmView.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteAsmView.dgvError.DataSource = frmStartCompleteAsmView.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteAsmView.RefleshLotBadData()
            Case DEF_ID_MOLD
                frmStartCompleteMold.ErrorTable = dtError.DefaultView.ToTable
                frmStartCompleteMold.dgvError.DataSource = frmStartCompleteMold.ErrorTable

                'ロット毎不良数ワークテーブル書込
                Call frmStartCompleteMold.RefleshLotBadData()
            'Case DEF_ID_KOHEN_DIESER_LINK
            '    frmStartCompletePkgDic.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompletePkgDic.dgvError.DataSource = frmStartCompletePkgDic.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompletePkgDic.RefleshLotBadData()
            'Case DEF_ID_KOHEN_DIESER
            '    frmStartCompletePkgDic.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompletePkgDic.dgvError.DataSource = frmStartCompletePkgDic.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompletePkgDic.RefleshLotBadData()
            'Case DEF_ID_M_DICER
            '    frmStartCompletePkgDic.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompletePkgDic.dgvError.DataSource = frmStartCompletePkgDic.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompletePkgDic.RefleshLotBadData()
            'Case DEF_ID_FT_BARIN
            '    frmStartCompleteFTB.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteFTB.dgvError.DataSource = frmStartCompleteFTB.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteFTB.RefleshLotBadData()
            'Case DEF_ID_FT_GAIKAN
            '    frmStartCompleteFTG.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteFTG.dgvError.DataSource = frmStartCompleteFTG.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteFTG.RefleshLotBadData()
            'Case DEF_ID_FT_SOUBATSU
            '    frmStartCompleteInOut.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteInOut.dgvError.DataSource = frmStartCompleteInOut.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteInOut.RefleshLotBadData()
            Case DEF_ID_MOLD_AFC
                'frmStartCompleteDbBake.ErrorTable = dtError.DefaultView.ToTable
                'frmStartCompleteDbBake.dgvError.DataSource = frmStartCompleteDbBake.ErrorTable
                defectNumCalc()
            'Case DEF_ID_FT_TESTER
            '    frmStartCompleteFTT.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteFTT.dgvError.DataSource = frmStartCompleteFTT.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteFTT.RefleshLotBadData()
            Case DEF_ID_PLASMA
                frmStartCompletePlasma.ErrorTable = dtError.DefaultView.ToTable
                frmStartCompletePlasma.dgvError.DataSource = frmStartCompletePlasma.ErrorTable

                'ロット毎不良数ワークテーブル書込
                Call frmStartCompletePlasma.RefleshLotBadData()
            'Case DEF_ID_EA_TESTER
            '    frmStartCompleteEAS.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteEAS.dgvError.DataSource = frmStartCompleteEAS.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteEAS.RefleshLotBadData()
            Case DEF_ID_MARK
                frmStartCompleteMark.ErrorTable = dtError.DefaultView.ToTable
                frmStartCompleteMark.dgvError.DataSource = frmStartCompleteMark.ErrorTable

                'ロット毎不良数ワークテーブル書込
                Call frmStartCompleteMark.RefleshLotBadData()
            Case DEF_ID_DBAFC
                'frmStartCompleteDbBake.ErrorTable = dtError.DefaultView.ToTable
                'frmStartCompleteDbBake.dgvError.DataSource = frmStartCompleteDbBake.ErrorTable

                defectNumCalc()
            'Case DEF_ID_FCBL
            '    frmStartCompleteBM.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteBM.dgvError.DataSource = frmStartCompleteBM.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteBM.RefleshLotBadData()
            'Case DEF_ID_WASH
            '    frmStartCompleteWashing.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteWashing.dgvError.DataSource = frmStartCompleteWashing.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteWashing.RefleshLotBadData()
            'Case DEF_ID_SHEET
            '    frmStartCompleteSheet.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteSheet.dgvError.DataSource = frmStartCompleteSheet.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteSheet.RefleshLotBadData()
            'Case DEF_ID_XSEN
            '    frmStartCompleteFTX.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteFTX.dgvError.DataSource = frmStartCompleteFTX.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteFTX.RefleshLotBadData()
            'Case DEF_ID_MBTC
            '    frmStartCompleteTrim.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteTrim.dgvError.DataSource = frmStartCompleteTrim.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteTrim.RefleshLotBadData()
            Case DEF_ID_MOLDQC
                frmStartCompletePlateCheck.ErrorTable = dtError.DefaultView.ToTable
                frmStartCompletePlateCheck.dgvError.DataSource = frmStartCompletePlateCheck.ErrorTable

                'ロット毎不良数ワークテーブル書込
                Call frmStartCompletePlateCheck.RefleshLotBadData()
            'Case DEF_ID_HAKO
            '    frmStartCompleteFTB.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteFTB.dgvError.DataSource = frmStartCompleteFTB.ErrorTable
            '    frmStartCompleteTaping.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteTaping.dgvError.DataSource = frmStartCompleteTaping.ErrorTable
            'Case DEF_ID_PUSH
            '    frmStartCompleteInOut.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteInOut.dgvError.DataSource = frmStartCompleteInOut.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteInOut.RefleshLotBadData()
            'Case DEF_ID_PULL
            '    frmStartCompletePull.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompletePull.dgvError.DataSource = frmStartCompletePull.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompletePull.RefleshLotBadData()
            'Case DEF_ID_E_PUSH
            '    frmStartCompleteInOut.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteInOut.dgvError.DataSource = frmStartCompleteInOut.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteInOut.RefleshLotBadData()
            'Case DEF_ID_ERASE
            '    frmStartCompleteFTB.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteFTB.dgvError.DataSource = frmStartCompleteFTB.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteFTB.RefleshLotBadData()
            'Case DEF_ID_E_PULL
            '    frmStartCompleteInOut.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteInOut.dgvError.DataSource = frmStartCompleteInOut.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteInOut.RefleshLotBadData()
            'Case DEF_ID_BIST
            '    frmStartCompleteFTB.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteFTB.dgvError.DataSource = frmStartCompleteFTB.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteFTB.RefleshLotBadData()
            'Case DEF_ID_BIST_BK
            '    frmStartCompleteBistBk.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteBistBk.dgvError.DataSource = frmStartCompleteBistBk.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteBistBk.RefleshLotBadData()
            'Case DEF_ID_HS
            '    frmStartCompleteHS.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteHS.dgvError.DataSource = frmStartCompleteHS.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteHS.RefleshLotBadData()
            'Case DEF_ID_HS_BAKE
            '    frmStartCompleteHsBake.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteHsBake.dgvError.DataSource = frmStartCompleteHsBake.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteHsBake.RefleshLotBadData()
            'Case DEF_ID_HS_PLASMA
            '    frmStartCompleteHsPlasma.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteHsPlasma.dgvError.DataSource = frmStartCompleteHsPlasma.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteHsPlasma.RefleshLotBadData()
            'Case DEF_ID_PIXTUKA
            '    frmStartCompletePickUp.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompletePickUp.dgvError.DataSource = frmStartCompletePickUp.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompletePickUp.RefleshLotBadData()
            'Case DEF_ID_P_CHECK
            '    frmStartCompleteCheck.Show()
            '    frmStartCompleteCheck.dgvError.DataSource = frmStartCompleteCheck.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteCheck.RefleshLotBadData()
            'Case DEF_ID_BARINUKI
            '    frmStartCompleteBari.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteBari.dgvError.DataSource = frmStartCompleteBari.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteBari.RefleshLotBadData()
            'Case DEF_ID_TEMPCYCLE
            '    frmStartCompleteTemp.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteTemp.dgvError.DataSource = frmStartCompleteTemp.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteTemp.RefleshLotBadData()
            'Case DEF_ID_MARKX
            '    frmStartCompleteMarkX.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteMarkX.dgvError.DataSource = frmStartCompleteMarkX.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteMarkX.RefleshLotBadData()
            'Case DEF_ID_GAIBAKE
            '    frmStartCompleteGBake.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteGBake.dgvError.DataSource = frmStartCompleteGBake.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteGBake.RefleshLotBadData()
            'Case DEF_ID_WATERJET
            '    frmStartCompleteWJ.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteWJ.dgvError.DataSource = frmStartCompleteWJ.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteWJ.RefleshLotBadData()
            'Case DEF_ID_AUTOX
            '    frmStartCompleteAutoX.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompleteAutoX.dgvError.DataSource = frmStartCompleteAutoX.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompleteAutoX.RefleshLotBadData()
            Case DEF_ID_PLATE
                'frmStartCompletePlate.ErrorTable = dtError.DefaultView.ToTable
                'frmStartCompletePlate.dgvError.DataSource = frmStartCompletePlate.ErrorTable
                defectNumCalc()
            Case DEF_ID_PLATING_BAKE
                'frmStartCompletePlatingBake.ErrorTable = dtError.DefaultView.ToTable
                'frmStartCompletePlatingBake.dgvError.DataSource = frmStartCompletePlatingBake.ErrorTable
                defectNumCalc()
            'Case DEF_ID_PQC
            '    frmStartCompletePQC.ErrorTable = dtError.DefaultView.ToTable
            '    frmStartCompletePQC.dgvError.DataSource = frmStartCompletePQC.ErrorTable

            '    'ロット毎不良数ワークテーブル書込
            '    Call frmStartCompletePQC.RefleshLotBadData()
            Case DEF_ID_DAM_CUT
                frmStartCompleteDamCutMold.ErrorTable = dtError.DefaultView.ToTable
                frmStartCompleteDamCutMold.dgvError.DataSource = frmStartCompleteDamCutMold.ErrorTable

                'ロット毎不良数ワークテーブル書込
                Call frmStartCompleteDamCutMold.RefleshLotBadData()
            Case DEF_ID_CUT
                frmStartCompleteCut.ErrorTable = dtError.DefaultView.ToTable
                frmStartCompleteCut.dgvError.DataSource = frmStartCompleteCut.ErrorTable

                'ロット毎不良数ワークテーブル書込
                Call frmStartCompleteCut.RefleshLotBadData()
                'Case DEF_ID_A_CUT_VIEW
                '    frmStartCompleteAfterCutView.ErrorTable = dtError.DefaultView.ToTable
                '    frmStartCompleteAfterCutView.dgvError.DataSource = frmStartCompleteAfterCutView.ErrorTable

                '    'ロット毎不良数ワークテーブル書込
                '    Call frmStartCompleteAfterCutView.RefleshLotBadData()
                'Case DEF_ID_VISUAL_VIEW
                '    frmStartCompleteVisualView.ErrorTable = dtError.DefaultView.ToTable
                '    frmStartCompleteVisualView.dgvError.DataSource = frmStartCompleteVisualView.ErrorTable

                '    'ロット毎不良数ワークテーブル書込
                '    Call frmStartCompleteVisualView.RefleshLotBadData()
                'Case DEF_ID_CHECKWORK
                '    frmStartCompleteCheckWork.ErrorTable = dtError.DefaultView.ToTable
                '    frmStartCompleteCheckWork.dgvError.DataSource = frmStartCompleteCheckWork.ErrorTable

                '    'ロット毎不良数ワークテーブル書込
                '    Call frmStartCompleteCheckWork.RefleshLotBadData()
                'Case DEF_ID_TAPING_BEFORE
                '    frmStartCompleteFTB.ErrorTable = dtError.DefaultView.ToTable
                '    frmStartCompleteFTB.dgvError.DataSource = frmStartCompleteFTB.ErrorTable

                '    'ロット毎不良数ワークテーブル書込
                '    Call frmStartCompleteFTB.RefleshLotBadData()
                'Case DEF_ID_PACKING
                '    frmStartCompleteFTB.ErrorTable = dtError.DefaultView.ToTable
                '    frmStartCompleteFTB.dgvError.DataSource = frmStartCompleteFTB.ErrorTable

                '    'ロット毎不良数ワークテーブル書込
                '    Call frmStartCompleteFTB.RefleshLotBadData()
                'Case DEF_ID_TAPING
                '    frmStartCompleteFTB.ErrorTable = dtError.DefaultView.ToTable
                '    frmStartCompleteFTB.dgvError.DataSource = frmStartCompleteFTB.ErrorTable

                '    'ロット毎不良数ワークテーブル書込
                '    Call frmStartCompleteFTB.RefleshLotBadData()
                'Case DEF_ID_TAPING_VIEW
                '    frmStartCompleteTapingView.ErrorTable = dtError.DefaultView.ToTable
                '    frmStartCompleteTapingView.dgvError.DataSource = frmStartCompleteTapingView.ErrorTable

                '    'ロット毎不良数ワークテーブル書込
                '    Call frmStartCompleteTapingView.RefleshLotBadData()
                'Case DEF_ID_TEST_ABNORMAL
                '    frmStartCompleteTestAbnormal.ErrorTable = dtError.DefaultView.ToTable
                '    frmStartCompleteTestAbnormal.dgvError.DataSource = frmStartCompleteTestAbnormal.ErrorTable

                '    'ロット毎不良数ワークテーブル書込
                '    Call frmStartCompleteTestAbnormal.RefleshLotBadData()
                'Case DEF_ID_DUMMY
                '    frmStartCompleteTestAbnormal.ErrorTable = dtError.DefaultView.ToTable
                '    frmStartCompleteTestAbnormal.dgvError.DataSource = frmStartCompleteTestAbnormal.ErrorTable
        End Select

        If preProcCompleteCnt < erroCount Then
            '>> 2018/02/19 安部 固定メッセージをメッセージマスタから取得に変更
            'MsgBox("不良数の合計が前工程完成数を上回っています。")
            MsgBox(getMsgStr("MSG10029"))
            '<< 2018/02/19 安部 固定メッセージをメッセージマスタから取得に変更
        Else
            Me.Close()
        End If


    End Sub

    '*****************************************************************************
    '　　不良カテゴリー取得処理
    '*****************************************************************************
    Private Sub DispCategoryInfo()
        'Dim i As Integer
        'Dim szTmp(CateMax) As String

        Dim dt As DataTable = cLotDefect.GetDefectCategory(g_CURRENT_EQUIP_TYPE)

        If Not IsNothing(dt) AndAlso dt.Columns.Count >= 2 Then
            Dim i As Integer = 1
            For Each dr As DataRow In dt.Rows
                btnCateAry(i).Text = dr("コード").ToString & ":" & dr("不良内容").ToString
                btnCateAry(i).Tag = dr("コード").ToString
                i += 1
            Next
        End If

        'With cLotCategoryInfo
        '●不良カテゴリー取得
        '    .GetCateInfo(frmLotKeijyou.g_EquipNo, frmLotKeijyou.g_KouteiCode)

        '    不良カテゴリー表示()
        '    For i = 1 To CateMax
        '        frmLotKeijyou.CateNumInfo(i).iCnt = .CateInfo(i).iCnt
        '        frmLotKeijyou.CateNumInfo(i).iNo = .CateInfo(i).iNo
        '        frmLotKeijyou.CateNumInfo(i).isub = .CateInfo(i).iSub
        '        frmLotKeijyou.CateNumInfo(i).szCode = cLotCategoryInfo.CateInfo(i).szCode
        '        frmLotKeijyou.CateNumInfo(i).szMess = cLotCategoryInfo.CateInfo(i).szMess

        '        szTmp(i) = VBStrings.FixCharLeftSpace(CStr(.CateInfo(i).iNo), 2) & "/" & .CateInfo(i).szCode & CStr(.CateInfo(i).iSub)
        '        btnCateAry(i).Text = "  " & szTmp(i) & "  " & .CateInfo(i).szMess
        '        btnCateAry(i).Enabled = CBool(IIf("" <> .CateInfo(i).szMess, True, False))
        '    Next

        '    For i = 0 To 4
        '        TabCategory.TabPages(i).Text = szTmp(i * 10 + 1) & " - " & szTmp(i * 10 + 10)
        '    Next i

        'End With


        'btnCate1.Text = "ダイ吸着（紛失）"
        'btnCate2.Text = "ＤＢフレーム破損"
        'btnCate3.Text = "ダイ位置ズレ"
        'btnCate4.Text = "ダイワレ・カケ"
        'btnCate5.Text = "ダイキズ"
        'btnCate6.Text = "逆・裏ダイ"
        'btnCate7.Text = "ペースト付着"
        'btnCate8.Text = "ＤＢその他"

        'btnCate1.Tag = "ダイ吸着（紛失）"
        'btnCate2.Tag = "ＤＢフレーム破損"
        'btnCate3.Tag = "ダイ位置ズレ"
        'btnCate4.Tag = "ダイワレ・カケ"
        'btnCate5.Tag = "ダイキズ"
        'btnCate6.Tag = "逆・裏ダイ"
        'btnCate7.Tag = "ペースト付着"
        'btnCate8.Tag = "ＤＢその他"

    End Sub

    Private Sub SetErrorCount()
        Dim dt As DataTable = cLotDefect.GetDefectData(szLotNo, szEquipID, szKouteiCD)
        Dim l_inspection_qty_type As Integer

        If Not IsNothing(dt) AndAlso dt.Columns.Count >= 2 And dt.Rows.Count > 0 Then
            l_inspection_qty_type = cLotDefect.GetInspection_Qty_Type(szLotNo, szEquipID, szKouteiCD)
            If l_inspection_qty_type = 1 Then
                rdbFull.Checked = True
                rdbSample.Checked = False
            ElseIf l_inspection_qty_type = 2 Then
                rdbSample.Checked = True
                rdbFull.Checked = False
            End If

            For Each dr As DataRow In dt.Rows
                For i = 1 To CateMax
                    If Not IsNothing(btnCateAry(i).Tag) Then
                        If dr("コード").ToString = btnCateAry(i).Tag.ToString Then
                            lblCountAry(i).Text = dr("数量").ToString
                            Exit For
                        End If
                    End If
                Next i

                'Select Case dr("コード").ToString
                '    Case btnCate1.Tag.ToString
                '        lblCount1.Text = dr("数量").ToString
                '    Case btnCate2.Tag.ToString
                '        lblCount2.Text = dr("数量").ToString
                '    Case btnCate3.Tag.ToString
                '        lblCount3.Text = dr("数量").ToString
                '    Case btnCate4.Tag.ToString
                '        lblCount4.Text = dr("数量").ToString
                '    Case btnCate5.Tag.ToString
                '        lblCount5.Text = dr("数量").ToString
                '    Case btnCate6.Tag.ToString
                '        lblCount6.Text = dr("数量").ToString
                '    Case btnCate7.Tag.ToString
                '        lblCount7.Text = dr("数量").ToString
                '    Case btnCate8.Tag.ToString
                '        lblCount8.Text = dr("数量").ToString
                'End Select
            Next
        Else
            If g_inspection_qty_type = 1 Then
                rdbFull.Checked = True
                rdbSample.Checked = False
            ElseIf g_inspection_qty_type = 2 Then

                rdbSample.Checked = True
                rdbFull.Checked = False
            End If
        End If
    End Sub

    '******************************************************************************
    '*  入力項目選択処理
    '******************************************************************************
    Private Sub btnCateAry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If m_CategoryNo > 0 Then
            btnCateAry(m_CategoryNo).BackColor = Color.Red
        End If
        Dim index As Integer = -1
        Dim i As Integer
        For i = 1 To btnCateAry.Length - 1
            If btnCateAry(i).Equals(sender) Then
                index = i
                Exit For
            End If
        Next i

        If 0 < index Then
            m_CategoryNo = index
            'lblCateSel.Text = VBStrings.FixCharLeftSpace(CStr(cLotCategoryInfo.CateInfo(index).iNo), 2) & "/" & cLotCategoryInfo.CateInfo(index).szCode & CStr(cLotCategoryInfo.CateInfo(i).iSub) & " " & cLotCategoryInfo.CateInfo(index).szMess
            'txtCateNum.Text = CStr(frmLotKeijyou.CateNumInfo(index).iNum)
            lblCateSel.Text = btnCateAry(index).Text
            txtCateNum.Text = lblCountAry(index).Text
            txtCateNum.Focus()
            btnCateAry(m_CategoryNo).BackColor = Color.DodgerBlue
            btnSet.Enabled = True
            PanelKey.Enabled = True
            btnCateNum.Enabled = True
        End If

    End Sub

    '******************************************************************************
    '*  数量入力項目選択処理
    '******************************************************************************
    Private Sub btnCateNum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCateNum.Click

        txtCateNum.Focus()

    End Sub

    Private Sub txtCateNum_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCateNum.GotFocus

        txtCateNum.BackColor = Color.Cyan

    End Sub

    Private Sub txtCateNum_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCateNum.LostFocus

        txtCateNum.BackColor = Color.Yellow

    End Sub

    '******************************************************************************
    '*  数量入力処理
    '******************************************************************************
    Private Sub btnSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSet.Click

        If True = IsNumeric(txtCateNum.Text) Then
            If 0 < CInt(txtCateNum.Text) Then

                'frmLotKeijyou.CateNumInfo(m_CategoryNo).iNum = cint(txtCateNum.Text)
                lblCountAry(m_CategoryNo).Text = txtCateNum.Text
            Else
                lblCountAry(m_CategoryNo).Text = String.Empty
            End If
        Else
            lblCountAry(m_CategoryNo).Text = String.Empty
        End If

    End Sub

    '******************************************************************************
    '*  キー入力処理
    '******************************************************************************
    Private Sub btnKeyAry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim index As Integer = -1
        Dim i As Integer
        For i = 0 To btnKeyAry.Length - 1
            If btnKeyAry(i).Equals(sender) Then
                index = i
                Exit For
            End If
        Next i

        Select Case index
            Case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
                'If "0" = Trim(txtCateNum.Text) Then
                '    txtCateNum.Text = ""
                'End If
                'txtCateNum.Text = Trim(txtCateNum.Text) & index

                Dim btnKey As Button = CType(sender, Button)
                Dim strKey As String = btnKey.Text
                If txtCateNum.Text.Equals("0") Then
                    txtCateNum.Text = strKey
                Else
                    txtCateNum.Text &= strKey
                End If
            Case 10
                txtCateNum.Text = String.Empty
        End Select

        txtCateNum.Focus()

    End Sub

    '********************************************************************************
    '       文字をセット
    '********************************************************************************
    Private Sub SetMsg()

        'Select Case g_NlsLanguage
        '    Case LANG_JAPANESE

        '    Case LANG_CHINESE
        '        Label1.Text = "不良项目"        '不良カテゴリー
        '        Label2.Text = "设备No"            '装置Ｎｏ
        '        btnCateNum.Text = "不良数"            '不良数
        '        btnSet.Text = "登録"                 '登録
        '        btnExit.Text = "終了"                   '終了

        '        Me.Text = "不良项目输入"          '不良カテゴリー入力

        'End Select

    End Sub

    ''' <summary>
    ''' 不良数合計計算
    ''' </summary>
    Private Sub defectNumCalc()

        Dim defectNumDt As New DataTable
        defectNumDt.Columns.Add("コード")
        defectNumDt.Columns.Add("不良内容")
        defectNumDt.Columns.Add("数量")

        defectNumDt.Clear()

        Dim i As Integer
        For i = 1 To CateMax
            If IsNumeric(lblCountAry(i).Text) OrElse String.IsNullOrEmpty(lblCountAry(i).Text) Then
                Dim dr() As DataRow = defectNumDt.Select("不良内容='" & btnCateAry(i).Text & "'")
                If dr.Length <= 0 Then
                    defectNumDt.Rows.Add(btnCateAry(i).Tag, btnCateAry(i).Text.Substring(InStr(btnCateAry(i).Text, ":")), lblCountAry(i).Text)
                Else
                    dr(0)("数量") = lblCountAry(i).Text
                End If
            End If
        Next
        defectNumDt.DefaultView.RowFilter = "数量<>''"
        failCnt = 0
        For n As Integer = 0 To defectNumDt.Rows.Count - 1
            If IsNumeric(defectNumDt.Rows(n)("数量")) Then
                failCnt = failCnt + CInt(defectNumDt.Rows(n)("数量"))
            End If
        Next

    End Sub

End Class